package com.community.itelligentcommunity.community.communityProperty.service;

import com.community.itelligentcommunity.common.base.dao.GenericDao;
import com.community.itelligentcommunity.common.base.service.GenericService;
import com.community.itelligentcommunity.common.util.user.UserInfo;
import com.community.itelligentcommunity.community.communityProperty.dao.FireControlDao;
import com.community.itelligentcommunity.community.communityProperty.entity.FireControlInf;
import com.community.itelligentcommunity.community.communityProperty.entity.QueryFireControlInf;
import com.community.itelligentcommunity.sys.entity.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

@Service
@Transactional(rollbackFor={IllegalArgumentException.class})
public class FireControlService extends GenericService<FireControlInf, QueryFireControlInf> {

    @Autowired
    private FireControlDao fireControlDao;

    @Override
    protected GenericDao<FireControlInf, QueryFireControlInf> getDao() {
        return fireControlDao;
    }
    @Override
    public boolean save(FireControlInf entity) throws Exception{
        //获得操作人相关信息
        User user = UserInfo.getUser();
        entity.setCreateMgrId(user.getId());
        entity.setCreateMgrName(user.getNickName());
        return getDao().save(entity)>0;
    }

    /**
     * 更新
     * @param entity 修改对象
     * @return boolean
     * @throws Exception
     * */
    @Override
    public boolean update(FireControlInf entity) throws Exception{
        User user = UserInfo.getUser();
        entity.setCreateMgrId(user.getId());
        entity.setCreateMgrName(user.getNickName());
        return getDao().update(entity)>0;
    }
}
